#pragma once

#include "CustomMesh.h"
#include "D3DApp.h"

class TriGrid
	: public CustomMesh
{
public:
	TriGrid();
	TriGrid(int width, int height, float dx, float dz);
	~TriGrid();

protected:
	void Update(double dt);
	void Draw(ID3DXSprite& sprite, D3DXMATRIX& view, D3DXMATRIX& proj);
	void BuildVertexBuffer();
	void BuildIndexBuffer();

private:

	const D3DXCOLOR WHITE;
	const D3DXCOLOR BEACH_SAND;
	const D3DXCOLOR LIGHT_GREEN;
	const D3DXCOLOR DARK_GREEN;
	const D3DXCOLOR DARK_BROWN;

	float GetHeight(float x, float z, float base, float seed) const
	{
		return base * (z * sinf(seed * x) + x * cosf(seed * z));
	}

	D3DXHANDLE mhTime;
	D3DXHANDLE mhEyePos;
	D3DXHANDLE mhFogColor;
	D3DXHANDLE mhFogMinDist;
	D3DXHANDLE mhFogMaxDist;

	float mTileWidth, mTileDepth;
	int mWidth, mDepth;
	int mNumVertices;
	int mNumFaces;
};

